#pragma once

#include <vex/core/config.h>

namespace vex {

    namespace core {

        struct shared_tag {};

        class shared {
            int m_count;
        protected:
            shared() : m_count(1)
            {
            }

            VEX_DEFAULTED_DESTRUCTOR(shared);

            void add_ref()
            {
                ++m_count;
            }

            template<class TDeleter>
            void release(TDeleter p_deleter)
            {
                if (m_count-- == 1) {
                    p_deleter();
                }
            }

            bool has_synchronized_ref_count() const
            {
                return false;
            }

            virtual bool is_shareable() const
            {
                return true;
            }
        public:
            typedef shared_tag ownership_type;
        };
    }

    using core::shared;
    using core::shared_tag;
}